function count_same_elements(collection) {
  //在这里写入代码
  let arr = [];
  let obj = {};
  for(let item of collection){
    if(!obj[item]){
      obj[item] = {};
      if(item.length >1){
        obj[item].key = item[0];
        obj[item].count = parseInt(item[2]);
      }
      else{
        obj[item].key = item;
        obj[item].count = 1;
      }
    }
    else{
      obj[item].count++;
    }
  }
  for(let item in obj){
    arr.push(obj[item]);
  }
  return arr;
}

module.exports = count_same_elements;
